<?php


namespace app\jiangnan\controller;


use app\utils\Constant;
use app\utils\JwtUtils;
use app\utils\StringUtils;
use think\Controller;
use think\Db;

class Pklot extends Controller
{

    public function getList(){
        $accessToken=request()->header("accessToken");
        $userResult=JwtUtils::getDecodeToken($accessToken);
        $userInfo=Db::table("userinfo")->where("userid",$userResult["userid"])->find();
        if(empty($userInfo)){
            return json(["code"=>10030,'msg' => '用户未绑定房屋']);
        }
        $pklotStatus=false;
        $roominfo=Db::table("roominfo")->where("id",$userInfo["room_id"])->find();
        if(!empty($roominfo["pklot"]) ){
            $pklotStatus=true;
        }


        //查询用户的车位号
        $pklotList=Db::table("cxyun_pklot")->where("empMoblie",$roominfo["phone"])->select();
        $pklotArr=array_column($pklotList,"pklot");

        return json(["code"=>0,'msg' => '获取成功',"pklotArr"=>$pklotArr,"pklotList"=>$pklotList,"roominfo"=>$roominfo,"pklotStatus"=>$pklotStatus]);
    }

}